package com.ruoyi.park.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import cn.hutool.core.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.park.mapper.WyRequisitionDetailMapper;
import com.ruoyi.park.domain.WyRequisitionDetail;
import com.ruoyi.park.service.IWyRequisitionDetailService;

/**
 * 领料详情Service业务层处理
 *
 * @author cjie
 * @date 2021-11-28
 */
@Service
public class WyRequisitionDetailServiceImpl implements IWyRequisitionDetailService {
    @Autowired
    private WyRequisitionDetailMapper wyRequisitionDetailMapper;

    /**
     * 查询领料详情
     *
     * @param id 领料详情ID
     * @return 领料详情
     */
    @Override
    public WyRequisitionDetail selectWyRequisitionDetailById(String id) {
        return wyRequisitionDetailMapper.selectWyRequisitionDetailById(id);
    }

    /**
     * 查询领料详情列表
     *
     * @param wyRequisitionDetail 领料详情
     * @return 领料详情
     */
    @Override
    public List<WyRequisitionDetail> selectWyRequisitionDetailList(WyRequisitionDetail wyRequisitionDetail) {
        return wyRequisitionDetailMapper.selectWyRequisitionDetailList(wyRequisitionDetail);
    }

    /**
     * 新增领料详情
     *
     * @param wyRequisitionDetail 领料详情
     * @return 结果
     */
    @Override
    public int insertWyRequisitionDetail(WyRequisitionDetail wyRequisitionDetail) {
        wyRequisitionDetail.setId(IdUtil.getSnowflake(0, 0).nextIdStr());
        wyRequisitionDetail.setCreateTime(DateUtils.getNowDate());
        wyRequisitionDetail.setCreateBy(SecurityUtils.getUsername());
        return wyRequisitionDetailMapper.insertWyRequisitionDetail(wyRequisitionDetail);
    }

    /**
     * 修改领料详情
     *
     * @param wyRequisitionDetail 领料详情
     * @return 结果
     */
    @Override
    public int updateWyRequisitionDetail(WyRequisitionDetail wyRequisitionDetail) {
        wyRequisitionDetail.setUpdateTime(DateUtils.getNowDate());
        wyRequisitionDetail.setUpdateBy(SecurityUtils.getUsername());
        return wyRequisitionDetailMapper.updateWyRequisitionDetail(wyRequisitionDetail);
    }

    /**
     * 批量删除领料详情
     *
     * @param ids 需要删除的领料详情ID
     * @return 结果
     */
    @Override
    public int deleteWyRequisitionDetailByIds(String[] ids) {
        return wyRequisitionDetailMapper.deleteWyRequisitionDetailByIds(ids);
    }

    /**
     * 删除领料详情信息
     *
     * @param id 领料详情ID
     * @return 结果
     */
    @Override
    public int deleteWyRequisitionDetailById(String id) {
        return wyRequisitionDetailMapper.deleteWyRequisitionDetailById(id);
    }
}
